package com.fingard.dsp.bank.directbank.specialDeal;


import java.sql.Connection;
import java.util.Map;

import com.fingard.FGBiz;
import com.fingard.db.JDBCHelper;

public class BankAreaHelper {

    public String bankCode = "";
    public String dspAreaCode = "";
    public String dspAreaName = "";
    public String bankAreaCode = "";
    public String bankAreaName = "";

    public BankAreaHelper(String p_BankCode, String p_AreaCode, String p_AreaName) {
        bankCode = p_BankCode;
        dspAreaCode = p_AreaCode;
        dspAreaName = p_AreaName;
    }

    private static String queryBankArea = "select bank_area_code bankareacode,bank_area_name bankareaname from tbl_dspcl_bank_area where bank_code=? and dsp_area_code=?";

    public void toBank() throws Exception {
        Connection dbConn = null;

        try {
            dbConn = FGBiz.dspCenter.dspSet.dbConnectionSet.getConnection();
            Map<String, Object> bankAreaMap = JDBCHelper.execQuerySingle(dbConn, queryBankArea, new Object[]{this.bankCode, this.dspAreaCode});
            if (bankAreaMap != null && bankAreaMap.size() > 0) {
                this.bankAreaCode = String.valueOf(bankAreaMap.get("bankareacode"));
                this.bankAreaName = String.valueOf(bankAreaMap.get("bankareaname"));
            } else {
                this.bankAreaCode = this.dspAreaCode;
                this.bankAreaName = this.dspAreaName;
            }

        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {

            if (dbConn != null) {
                dbConn.close();
            }
        }
    }
}
